import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Scanner;

public class C_1116 {
    public static void main(String[] args) {
        int b;
        int c;
        int flag = 0;
        int error;
        String s;
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextLine()){
            s = sc.nextLine();
            try {
                flag = 0;
                String[] a;
                a = s.split("\\.");
                for (String str:a){
                    if (str.charAt(0)=='0'||Integer.parseInt(str)>255||Integer.parseInt(str)<0)
                        flag = 1;
                }
                error = 0;
            }catch (Exception e ){
                System.out.println("N");
                error = 1;
            }
            if (flag==1&&error==0)
                System.out.println("N");
            if (flag==0&&error==0)
                System.out.println("Y");
        }
    }
}
